package com.todo.partner.application.convert;

import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.todo.common.common.entity.BaseUserVO;
import com.todo.common.common.entity.response.page.PageResult;
import com.todo.common.common.enums.AllowedCommentEnum;
import com.todo.common.common.enums.SourceEnum;
import com.todo.common.common.enums.biz.PrivateTypeEnum;
import com.todo.common.utils.TodoCommonUtils;
import com.todo.content.api.request.InsertContentDetailRequest;
import com.todo.content.api.request.SavePreCheckRequest;
import com.todo.content.api.request.UpdateContentDetailRequest;
import com.todo.content.api.response.ContentDetailResponse;
import com.todo.content.api.response.ContentInfoResponse;
import com.todo.content.common.enums.ContentStatusEnum;
import com.todo.partner.application.entity.bo.PartnerContentBO;
import com.todo.partner.application.entity.bo.PartnerContentDetailBO;
import com.todo.partner.application.entity.bo.PartnerInfoBO;
import com.todo.partner.application.entity.condition.ContentPartnerConditionBO;
import com.todo.partner.common.enums.PartnerContentTypeEnum;
import com.todo.partner.common.enums.PartnerRelationTypeEnum;
import com.todo.partner.iface.frontend.request.InsertContentPartnerParam;
import com.todo.partner.iface.frontend.request.QueryContentPartnerByPageParam;
import com.todo.partner.iface.frontend.request.UpdateContentPartnerByIdParam;
import com.todo.partner.iface.frontend.response.ContentPartnerBaseVO;
import com.todo.partner.iface.frontend.response.ContentPartnerDetailVO;
import com.todo.partner.infrastructure.entity.condition.ContentPartnerCondition;
import com.todo.partner.infrastructure.entity.po.ContentPartnerPO;
import com.todo.partner.service.api.response.PartnerDetailResponse;
import com.todo.partner.service.api.response.PartnerInfoResponse;
import com.todo.user.api.response.BaseUserInfoResponse;
import com.todo.user.api.response.BatchQuerySimplyUserInfoResponse;
import org.apache.commons.collections4.CollectionUtils;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author azhebuxing
 * @date 2024/4/23 16:46
 * @description
 */
public class PartnerConvert {
    public static SavePreCheckRequest convertToSavePreCheckRequest(PartnerContentDetailBO partnerContentDetailBO, Boolean isInsert) {
        if (partnerContentDetailBO == null || partnerContentDetailBO.getPartnerContentBO() == null) {
            return null;
        }
        SavePreCheckRequest request = new SavePreCheckRequest();

        PartnerContentBO partnerContentBO = partnerContentDetailBO.getPartnerContentBO();
        request.setIsInsert(isInsert);
        request.setContent(partnerContentBO.getContent());
        request.setClassifyCode("partner_content");
        request.setUserId(partnerContentBO.getUserId());
        request.setMainImg(partnerContentBO.getMainImg());
        request.setTitle(partnerContentBO.getTitle());
        request.setUserId(partnerContentBO.getUserId());
        request.setAllowComment(partnerContentBO.getAllowComment());
        request.setIsPrivate(partnerContentBO.getIsPrivate());
        return request;
    }

    public static InsertContentDetailRequest convertToInsertContentDetailRequest(PartnerContentDetailBO partnerContentDetailBO) {
        if (partnerContentDetailBO == null || partnerContentDetailBO.getPartnerContentBO() == null) {
            return null;
        }
        InsertContentDetailRequest request = new InsertContentDetailRequest();

        PartnerContentBO partnerContentBO = partnerContentDetailBO.getPartnerContentBO();
        request.setContent(partnerContentBO.getContent());
        request.setClassifyCode("partner_content");
        request.setUserId(partnerContentBO.getUserId());
        request.setMainImg(partnerContentBO.getMainImg());
        request.setTitle(partnerContentBO.getTitle());
        request.setUserId(partnerContentBO.getUserId());
        request.setAllowComment(partnerContentBO.getAllowComment());
        request.setIsPrivate(partnerContentBO.getIsPrivate());
        return request;
    }

    public static UpdateContentDetailRequest convertToUpdateContentDetailRequest(PartnerContentDetailBO partnerContentDetailBO) {
        if (partnerContentDetailBO == null || partnerContentDetailBO.getPartnerContentBO() == null) {
            return null;
        }
        UpdateContentDetailRequest request = new UpdateContentDetailRequest();

        PartnerContentBO partnerContentBO = partnerContentDetailBO.getPartnerContentBO();
        request.setContentId(partnerContentBO.getContentId());
        request.setContent(partnerContentBO.getContent());
        request.setClassifyCode("partner_content");
        request.setUserId(partnerContentBO.getUserId());
        request.setMainImg(partnerContentBO.getMainImg());
        request.setTitle(partnerContentBO.getTitle());
        request.setUserId(partnerContentBO.getUserId());
        request.setAllowComment(partnerContentBO.getAllowComment());
        request.setIsPrivate(partnerContentBO.getIsPrivate());
        return request;
    }

    public static ContentPartnerPO convertToContentPartnerPO(PartnerContentDetailBO partnerContentDetailBO) {
        if (partnerContentDetailBO == null) {
            return null;
        }
        PartnerContentBO partnerContentBO = partnerContentDetailBO.getPartnerContentBO();
        PartnerInfoBO partnerInfoBO = partnerContentDetailBO.getPartnerInfoBO();

        ContentPartnerPO contentPartnerPO = new ContentPartnerPO();
        contentPartnerPO.setContentId(partnerContentBO.getContentId());
        contentPartnerPO.setId(partnerInfoBO.getId() == null ? TodoCommonUtils.buildLongGuid() : partnerInfoBO.getId());
        contentPartnerPO.setExtra(JSONObject.toJSONString(partnerInfoBO.getExtra()));
        contentPartnerPO.setCity(partnerInfoBO.getCity());
        contentPartnerPO.setPartnerContentType(partnerInfoBO.getPartnerContentTypeEnum().getType());
        contentPartnerPO.setProvince(partnerInfoBO.getProvince());
        contentPartnerPO.setRelationId(partnerInfoBO.getRelationId());
        contentPartnerPO.setEndPlanTime(partnerInfoBO.getEndPlanTime());
        contentPartnerPO.setStartPlanTime(partnerInfoBO.getStartPlanTime());
        contentPartnerPO.setUserId(partnerContentBO.getUserId());
        contentPartnerPO.setRelationType(partnerInfoBO.getPartnerContentTypeEnum().getType());
        contentPartnerPO.setIsDelete(0);
        contentPartnerPO.setCreateTime(new Date());
        contentPartnerPO.setUpdateTime(new Date());
        return contentPartnerPO;
    }


    public static PartnerContentDetailBO buildPartnerContentDetailBO(ContentInfoResponse response, ContentPartnerPO contentPartnerPO) {
        if (response == null || contentPartnerPO == null) {
            return null;
        }
        PartnerContentDetailBO partnerContentDetailBO = new PartnerContentDetailBO();
        PartnerContentBO partnerContentBO = new PartnerContentBO();
        partnerContentBO.setContentId(response.getContentId());
        partnerContentBO.setContent(response.getContent());
        partnerContentBO.setTitle(response.getTitle());
        partnerContentBO.setUserId(response.getUserId());
        partnerContentBO.setStatus(response.getStatus());
        partnerContentBO.setAllowComment(response.getAllowComment());
        partnerContentBO.setSeeCount(response.getSeeCount());
        partnerContentBO.setLikeCount(response.getLikeCount());
        partnerContentBO.setCommentCount(response.getCommentCount());
        partnerContentBO.setIsPrivate(response.getIsPrivate());
        partnerContentBO.setMainImg(response.getMainImg());
        partnerContentBO.setSourceEnum(response.getSource());

        PartnerInfoBO partnerInfoBO = new PartnerInfoBO();
        partnerInfoBO.setCity(contentPartnerPO.getCity());
        partnerInfoBO.setUserId(contentPartnerPO.getUserId());
        partnerInfoBO.setContentId(contentPartnerPO.getContentId());
        partnerInfoBO.setEndPlanTime(contentPartnerPO.getEndPlanTime());
        partnerInfoBO.setStartPlanTime(contentPartnerPO.getStartPlanTime());
        partnerInfoBO.setExtra(JSONObject.parseObject(contentPartnerPO.getExtra(), PartnerInfoBO.Extra.class));
        partnerInfoBO.setPartnerContentTypeEnum(PartnerContentTypeEnum.getByType(contentPartnerPO.getPartnerContentType()));
        partnerInfoBO.setProvince(contentPartnerPO.getProvince());
        partnerInfoBO.setRelationId(contentPartnerPO.getRelationId());
        partnerInfoBO.setId(contentPartnerPO.getId());
        partnerInfoBO.setRelationType(PartnerRelationTypeEnum.getByType(contentPartnerPO.getRelationType()));

        partnerContentDetailBO.setPartnerContentBO(partnerContentBO);
        partnerContentDetailBO.setPartnerInfoBO(partnerInfoBO);
        return partnerContentDetailBO;
    }

    public static PartnerContentDetailBO buildPartnerContentDetailBO(ContentDetailResponse response, ContentPartnerPO contentPartnerPO) {
        if (response == null || contentPartnerPO == null) {
            return null;
        }
        PartnerContentDetailBO partnerContentDetailBO = new PartnerContentDetailBO();
        PartnerContentBO partnerContentBO = new PartnerContentBO();
        partnerContentBO.setContentId(response.getContentId());
        partnerContentBO.setContent(response.getContent());
        partnerContentBO.setTitle(response.getTitle());
        partnerContentBO.setUserId(response.getUserId());
        partnerContentBO.setStatus(response.getStatus());
        partnerContentBO.setAllowComment(response.getAllowComment());
        partnerContentBO.setSeeCount(response.getSeeCount());
        partnerContentBO.setLikeCount(response.getLikeCount());
        partnerContentBO.setCommentCount(response.getCommentCount());
        partnerContentBO.setIsPrivate(response.getIsPrivate());
        partnerContentBO.setMainImg(response.getMainImg());

        PartnerInfoBO partnerInfoBO = new PartnerInfoBO();
        partnerInfoBO.setUserId(contentPartnerPO.getUserId());
        partnerInfoBO.setCity(contentPartnerPO.getCity());
        partnerInfoBO.setExtra(JSONObject.parseObject(contentPartnerPO.getExtra(), PartnerInfoBO.Extra.class));
        partnerInfoBO.setPartnerContentTypeEnum(PartnerContentTypeEnum.getByType(contentPartnerPO.getPartnerContentType()));
        partnerInfoBO.setProvince(contentPartnerPO.getProvince());
        partnerInfoBO.setRelationId(contentPartnerPO.getRelationId());
        partnerInfoBO.setEndPlanTime(contentPartnerPO.getEndPlanTime());
        partnerInfoBO.setStartPlanTime(contentPartnerPO.getStartPlanTime());
        partnerInfoBO.setId(contentPartnerPO.getId());
        partnerInfoBO.setContentId(contentPartnerPO.getContentId());
        partnerInfoBO.setRelationType(PartnerRelationTypeEnum.getByType(contentPartnerPO.getRelationType()));

        partnerContentDetailBO.setPartnerContentBO(partnerContentBO);
        partnerContentDetailBO.setPartnerInfoBO(partnerInfoBO);
        return partnerContentDetailBO;
    }

    public static ContentPartnerCondition convertToContentPartnerCondition(ContentPartnerConditionBO conditionBO) {
        if (conditionBO == null) {
            return null;
        }
        ContentPartnerCondition condition = new ContentPartnerCondition();
        condition.setContentId(conditionBO.getContentId());
        condition.setRelationType(conditionBO.getRelationType() == null ? null : conditionBO.getRelationType().getType());
        condition.setPartnerContentType(conditionBO.getPartnerContentType() == null ? null : conditionBO.getPartnerContentType().getType());
        condition.setProvince(conditionBO.getProvince());
        condition.setCity(conditionBO.getCity());
        condition.setPageIndex(conditionBO.getPageIndex());
        condition.setPageSize(conditionBO.getPageSize());
        condition.setStartPlanTime(conditionBO.getStartPlanTime());
        condition.setEndPlanTime(conditionBO.getEndPlanTime());
        condition.setCurrentIndex(conditionBO.getCurrentIndex());
        condition.setUserId(conditionBO.getUserId());
        condition.setRelationId(conditionBO.getRelationId());
        condition.setRelationType(conditionBO.getRelationType() == null ? null : conditionBO.getRelationType().getType());
        return condition;
    }

    public static PartnerDetailResponse convertToPartnerDetailResponse(PartnerContentDetailBO partnerContentDetailBO) {
        if (partnerContentDetailBO == null || partnerContentDetailBO.getPartnerInfoBO() == null) {
            return null;
        }
        PartnerDetailResponse response = new PartnerDetailResponse();
        PartnerInfoBO partnerInfoBO = partnerContentDetailBO.getPartnerInfoBO();
        PartnerContentBO partnerContentBO = partnerContentDetailBO.getPartnerContentBO();
        response.setPartnerId(partnerInfoBO.getId());
        response.setUserId(partnerInfoBO.getUserId());
        response.setContentId(partnerInfoBO.getContentId());
        response.setPartnerContentTypeEnum(partnerInfoBO.getPartnerContentTypeEnum());
        response.setRelationType(partnerInfoBO.getRelationType());
        response.setRelationId(partnerInfoBO.getRelationId());
        response.setProvince(partnerInfoBO.getProvince());
        response.setCity(partnerInfoBO.getCity());
        response.setStartPlanTime(partnerInfoBO.getStartPlanTime());
        response.setEndPlanTime(partnerInfoBO.getEndPlanTime());
        if (partnerInfoBO.getExtra() != null) {
            response.setExpectCost(partnerInfoBO.getExtra().getExpectCost());
            response.setExpectPeopleCount(partnerInfoBO.getExtra().getExpectPeopleCount());
        }
        response.setTitle(partnerContentBO.getTitle());
        response.setContent(partnerContentBO.getContent());
        response.setMainImg(partnerContentBO.getMainImg());
        response.setStatus(partnerContentBO.getStatus());
        response.setIsPrivate(partnerContentBO.getIsPrivate());
        response.setAllowComment(partnerContentBO.getAllowComment());
        response.setSeeCount(partnerContentBO.getSeeCount());
        response.setLikeCount(partnerContentBO.getLikeCount());
        response.setCommentCount(partnerContentBO.getCommentCount());
        response.setSourceEnum(partnerContentBO.getSourceEnum());
        return response;
    }

    public static List<PartnerInfoResponse> convertToPartnerInfoResponseList(List<PartnerContentDetailBO> partnerContentDetailBOS) {
        if (CollectionUtils.isEmpty(partnerContentDetailBOS)) {
            return Lists.newArrayList();
        }
        return partnerContentDetailBOS.stream().map(PartnerConvert::convertToPartnerInfoResponse).collect(Collectors.toList());
    }

    private static PartnerInfoResponse convertToPartnerInfoResponse(PartnerContentDetailBO partnerContentDetailBO) {
        if (partnerContentDetailBO == null || partnerContentDetailBO.getPartnerInfoBO() == null) {
            return null;
        }
        PartnerInfoResponse response = new PartnerInfoResponse();
        PartnerInfoBO partnerInfoBO = partnerContentDetailBO.getPartnerInfoBO();
        PartnerContentBO partnerContentBO = partnerContentDetailBO.getPartnerContentBO();
        response.setPartnerId(partnerInfoBO.getId());
        response.setUserId(partnerInfoBO.getUserId());
        response.setContentId(partnerInfoBO.getContentId());
        response.setPartnerContentTypeEnum(partnerInfoBO.getPartnerContentTypeEnum());
        response.setRelationType(partnerInfoBO.getRelationType());
        response.setRelationId(partnerInfoBO.getRelationId());
        response.setProvince(partnerInfoBO.getProvince());
        response.setCity(partnerInfoBO.getCity());
        response.setStartPlanTime(partnerInfoBO.getStartPlanTime());
        response.setEndPlanTime(partnerInfoBO.getEndPlanTime());
        if (partnerInfoBO.getExtra() != null) {
            response.setExpectCost(partnerInfoBO.getExtra().getExpectCost());
            response.setExpectPeopleCount(partnerInfoBO.getExtra().getExpectPeopleCount());
        }
        response.setTitle(partnerContentBO.getTitle());
        response.setContent(partnerContentBO.getContent());
        response.setMainImg(partnerContentBO.getMainImg());
        response.setStatus(partnerContentBO.getStatus());
        response.setSeeCount(partnerContentBO.getSeeCount());
        response.setLikeCount(partnerContentBO.getLikeCount());
        response.setCommentCount(partnerContentBO.getCommentCount());
        return response;
    }

    public static PartnerContentDetailBO convertToPartnerContentDetailBO(InsertContentPartnerParam param) {
        if (param == null) {
            return null;
        }
        PartnerContentDetailBO partnerContentDetailBO = new PartnerContentDetailBO();

        Long contentId = TodoCommonUtils.buildLongGuid();
        PartnerInfoBO partnerInfoBO = new PartnerInfoBO();
        partnerInfoBO.setId(TodoCommonUtils.buildLongGuid());
        partnerInfoBO.setContentId(contentId);
        partnerInfoBO.setCity(param.getCity());
        partnerInfoBO.setPartnerContentTypeEnum(PartnerContentTypeEnum.getByType(param.getPartnerContentType()));
        partnerInfoBO.setProvince(param.getProvince());
        partnerInfoBO.setRelationType(PartnerRelationTypeEnum.getByType(param.getRelationType()));
        partnerInfoBO.setRelationId(param.getRelationId());
        partnerInfoBO.setStartPlanTime(param.getStartPlanTime());
        partnerInfoBO.setEndPlanTime(param.getEndPlanTime());
        partnerInfoBO.setExtra(new PartnerInfoBO.Extra());
        partnerInfoBO.getExtra().setExpectPeopleCount(param.getExpectPeopleCount());
        partnerInfoBO.getExtra().setExpectCost(param.getExpectCost());

        PartnerContentBO partnerContentBO = new PartnerContentBO();
        partnerContentBO.setContentId(contentId);
        partnerContentBO.setTitle(param.getTitle());
        partnerContentBO.setContent(param.getContent());
        partnerContentBO.setMainImg(param.getMainImg());
        partnerContentBO.setAllowComment(AllowedCommentEnum.getByType(param.getAllowComment()));
        partnerContentBO.setStatus(ContentStatusEnum.POSTED);
        partnerContentBO.setIsPrivate(PrivateTypeEnum.getByType(param.getIsPrivate()));
        partnerContentBO.setSeeCount(0);
        partnerContentBO.setCommentCount(0);
        partnerContentBO.setLikeCount(0);
        partnerContentBO.setUserId(param.get_user().getUserId());
        partnerContentBO.setSourceEnum(SourceEnum.getByType(param.get_user().getSource()));

        partnerContentDetailBO.setPartnerInfoBO(partnerInfoBO);
        partnerContentDetailBO.setPartnerContentBO(partnerContentBO);
        return partnerContentDetailBO;
    }

    public static PartnerContentDetailBO convertToUpdateContentPartnerRequest(UpdateContentPartnerByIdParam param) {
        if (param == null) {
            return null;
        }
        PartnerContentDetailBO partnerContentDetailBO = new PartnerContentDetailBO();

        PartnerInfoBO partnerInfoBO = new PartnerInfoBO();
        partnerInfoBO.setId(Long.valueOf(param.getPartnerId()));
        partnerInfoBO.setCity(param.getCity());
        partnerInfoBO.setPartnerContentTypeEnum(PartnerContentTypeEnum.getByType(param.getPartnerContentType()));
        partnerInfoBO.setProvince(param.getProvince());
        partnerInfoBO.setRelationType(PartnerRelationTypeEnum.getByType(param.getRelationType()));
        partnerInfoBO.setRelationId(param.getRelationId());
        partnerInfoBO.setStartPlanTime(param.getStartPlanTime());
        partnerInfoBO.setEndPlanTime(param.getEndPlanTime());
        partnerInfoBO.setExtra(new PartnerInfoBO.Extra());
        partnerInfoBO.getExtra().setExpectPeopleCount(param.getExpectPeopleCount());
        partnerInfoBO.getExtra().setExpectCost(param.getExpectCost());

        PartnerContentBO partnerContentBO = new PartnerContentBO();
        partnerContentBO.setTitle(param.getTitle());
        partnerContentBO.setContentId(Long.valueOf(param.getContentId()));
        partnerContentBO.setContent(param.getContent());
        partnerContentBO.setMainImg(param.getMainImg());
        partnerContentBO.setAllowComment(AllowedCommentEnum.getByType(param.getAllowComment()));
        partnerContentBO.setStatus(ContentStatusEnum.POSTED);
        partnerContentBO.setIsPrivate(PrivateTypeEnum.getByType(param.getIsPrivate()));
        partnerContentBO.setSeeCount(0);
        partnerContentBO.setCommentCount(0);
        partnerContentBO.setLikeCount(0);
        partnerContentBO.setUserId(param.get_user().getUserId());

        partnerContentDetailBO.setPartnerInfoBO(partnerInfoBO);
        partnerContentDetailBO.setPartnerContentBO(partnerContentBO);
        return partnerContentDetailBO;
    }

    public static ContentPartnerDetailVO buildContentPartnerDetailVO(PartnerContentDetailBO partnerContentDetailBO, BaseUserInfoResponse userInfoResponse) {
        if (partnerContentDetailBO == null || partnerContentDetailBO.getPartnerInfoBO() == null || userInfoResponse == null) {
            return null;
        }
        PartnerInfoBO partnerInfoBO = partnerContentDetailBO.getPartnerInfoBO();
        PartnerContentBO partnerContentBO = partnerContentDetailBO.getPartnerContentBO();
        ContentPartnerDetailVO contentPartnerDetailVO = new ContentPartnerDetailVO();
        contentPartnerDetailVO.setBaseUserVO(baseUserVOValueOf(userInfoResponse));
        contentPartnerDetailVO.setCity(partnerInfoBO.getCity());
        contentPartnerDetailVO.setTitle(partnerContentBO.getTitle());
        contentPartnerDetailVO.setIsPrivate(partnerContentBO.getIsPrivate() == null ? 0 : partnerContentBO.getIsPrivate().getType());
        contentPartnerDetailVO.setAllowComment(partnerContentBO.getAllowComment() == null ? 0 : partnerContentBO.getAllowComment().getType());
        contentPartnerDetailVO.setCommentCount(partnerContentBO.getCommentCount());
        contentPartnerDetailVO.setContent(partnerContentBO.getContent());
        contentPartnerDetailVO.setContentId(partnerInfoBO.getContentId());
        contentPartnerDetailVO.setEndPlanTime(partnerInfoBO.getEndPlanTime());
        if (partnerInfoBO.getExtra() != null) {
            contentPartnerDetailVO.setExpectCost(partnerInfoBO.getExtra().getExpectCost());
            contentPartnerDetailVO.setExpectPeopleCount(partnerInfoBO.getExtra().getExpectPeopleCount());
        }
        contentPartnerDetailVO.setLikeCount(partnerContentBO.getLikeCount());
        contentPartnerDetailVO.setMainImg(partnerContentBO.getMainImg());
        contentPartnerDetailVO.setPartnerContentType(partnerInfoBO.getPartnerContentTypeEnum().getType());
        contentPartnerDetailVO.setPartnerContentTypeStr(partnerInfoBO.getPartnerContentTypeEnum().getName());
        contentPartnerDetailVO.setPartnerId(partnerInfoBO.getId());
        contentPartnerDetailVO.setProvince(partnerInfoBO.getProvince());
        contentPartnerDetailVO.setRelationId(partnerInfoBO.getRelationId());
        contentPartnerDetailVO.setRelationType(partnerInfoBO.getRelationType().getType());
        contentPartnerDetailVO.setSeeCount(partnerContentBO.getSeeCount());
        contentPartnerDetailVO.setStartPlanTime(partnerInfoBO.getStartPlanTime());
        return contentPartnerDetailVO;
    }

    public static BaseUserVO baseUserVOValueOf(BaseUserInfoResponse userInfoResponse) {
        if (userInfoResponse == null) {
            return null;
        }
        BaseUserVO baseUserVO = new BaseUserVO();
        baseUserVO.setUserId(String.valueOf(userInfoResponse.getUserId()));
        baseUserVO.setUserName(userInfoResponse.getUserName());
        baseUserVO.setUserNikeName(userInfoResponse.getNickName());
        baseUserVO.setUserAvatar(userInfoResponse.getHeadImg());
        return baseUserVO;
    }

    public static ContentPartnerConditionBO convertToContentPartnerConditionBO(QueryContentPartnerByPageParam param) {
        if (param == null) {
            return null;
        }
        ContentPartnerConditionBO conditionBO = new ContentPartnerConditionBO();
        conditionBO.setCity(param.getCity());
        conditionBO.setEndPlanTime(param.getEndPlanTime());
        conditionBO.setPageIndex(param.getPageIndex());
        conditionBO.setPageSize(param.getPageSize());
        conditionBO.setPageIndex(param.getPageIndex());
        conditionBO.setPartnerContentType(PartnerContentTypeEnum.getByType(param.getPartnerContentType()));
        conditionBO.setStartPlanTime(param.getStartPlanTime());
        conditionBO.setUserId(param.get_user().getUserId());
        return conditionBO;
    }

    public static PageResult<ContentPartnerBaseVO> buildContentPartnerDetailResponsePage(PageResult<PartnerContentDetailBO> pageResult, Map<Long, BatchQuerySimplyUserInfoResponse.SimplyUserInfo> simplyUserInfoMap) {
        if (pageResult == null || simplyUserInfoMap == null) {
            return null;
        }
        if (CollectionUtils.isEmpty(pageResult.getResults())) {
            return PageResult.of(new ArrayList<>(), pageResult.getPageNum(), pageResult.getPageSize(), pageResult.getTotal(), pageResult.getCurrentIndex());
        }
        PageResult<ContentPartnerBaseVO> result = new PageResult<>();
        result.setPageCount(pageResult.getPageCount());
        result.setPageNum(pageResult.getPageNum());
        result.setPageSize(pageResult.getPageSize());
        result.setTotal(pageResult.getTotal());
        result.setHasNext(pageResult.isHasNext());
        List<PartnerContentDetailBO> results = pageResult.getResults();
        List<ContentPartnerBaseVO> contentPartnerBaseVOList = new ArrayList<>();
        for (PartnerContentDetailBO response : results) {
            ContentPartnerBaseVO contentPartnerBaseVO = new ContentPartnerBaseVO();
            PartnerInfoBO partnerInfoBO = response.getPartnerInfoBO();
            PartnerContentBO partnerContentBO = response.getPartnerContentBO();
            contentPartnerBaseVO.setCity(partnerInfoBO.getCity());
            contentPartnerBaseVO.setCommentCount(partnerContentBO.getCommentCount());
            contentPartnerBaseVO.setContent(partnerContentBO.getContent());
            contentPartnerBaseVO.setContentId(partnerInfoBO.getContentId());
            contentPartnerBaseVO.setEndPlanTime(partnerInfoBO.getEndPlanTime());
            if (partnerInfoBO.getExtra() != null) {
                contentPartnerBaseVO.setExpectCost(partnerInfoBO.getExtra().getExpectCost());
                contentPartnerBaseVO.setExpectPeopleCount(partnerInfoBO.getExtra().getExpectPeopleCount());
            }
            contentPartnerBaseVO.setLikeCount(partnerContentBO.getLikeCount());
            contentPartnerBaseVO.setMainImg(partnerContentBO.getMainImg());
            contentPartnerBaseVO.setPartnerContentType(partnerInfoBO.getPartnerContentTypeEnum().getType());
            contentPartnerBaseVO.setPartnerContentTypeStr(partnerInfoBO.getPartnerContentTypeEnum().getName());
            contentPartnerBaseVO.setPartnerId(partnerInfoBO.getId());
            contentPartnerBaseVO.setProvince(partnerInfoBO.getProvince());
            contentPartnerBaseVO.setSeeCount(partnerContentBO.getSeeCount());
            contentPartnerBaseVO.setStartPlanTime(partnerInfoBO.getStartPlanTime());
            contentPartnerBaseVO.setTitle(partnerContentBO.getTitle());
            if (simplyUserInfoMap.containsKey(partnerInfoBO.getUserId())) {
                BatchQuerySimplyUserInfoResponse.SimplyUserInfo simplyUserInfo = simplyUserInfoMap.get(partnerInfoBO.getUserId());
                BaseUserVO baseUserVO = new BaseUserVO();
                baseUserVO.setUserAvatar(simplyUserInfo.getUserAvatar());
                baseUserVO.setUserId(String.valueOf(simplyUserInfo.getUserId()));
                baseUserVO.setUserNikeName(simplyUserInfo.getUserNikeName());
                contentPartnerBaseVO.setBaseUserVO(baseUserVO);
            }
            contentPartnerBaseVOList.add(contentPartnerBaseVO);
        }
        result.setResults(contentPartnerBaseVOList);
        return result;
    }
}
